package es.udc.emarketapp.http.view.actionForms;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import es.udc.fbellas.j2ee.util.struts.action.PropertyValidator;
import es.udc.fbellas.j2ee.util.struts.action.DefaultActionForm;

public class CategoryForm extends DefaultActionForm {

    private Long idCat;
    private Long catFather;
    private String nomCat;

    public CategoryForm() {
        reset();
    }

    public Long getIdCat() {
        return idCat;
    }

    public void setIdCat(Long idCat) {
        this.idCat = idCat;
    }

    public String getNomCat() {
        return nomCat;
    }

    public void setNomCat(String nomCat) {
        this.nomCat = nomCat;
    }

    public Long getCatFather() {
        return catFather;
    }

    public void setCatFather(Long catFather) {
        this.catFather = catFather;
    }

 
    public ActionErrors validate(ActionMapping mapping,
            HttpServletRequest request) {

        ActionErrors errors = new ActionErrors();
        PropertyValidator.validateMandatory(errors, "nomCat", nomCat);
        PropertyValidator.validateLong(errors, "catFather", "catFather", true, 1, 100);

        return errors;

    }

    private void reset() {
        idCat = null;
        catFather = null;
        nomCat = null;
    }
}
